#pragma once
#include <widgets/SDialog.h>
#include <QStylePainter>
#include <vector>
#include <list>
#include <map>

class STabCtrl;
class InterestRateBondList;
class InterestRateBondChart;
class CRateBondList;


class InterestRateBondIssuance : public SDialog
{
public:
	enum listCol {
		COL_TERM = 0,			//期限
		COL_NAME,				//债券简称
		COL_ISSUEDATE,			//发行日
		COL_AUCTION_TIME,		//招标时间
		COL_ISSUE_AMOUNT,		//发行量
		COL_ISSUE_RATE,			//加权利率
		COL_MARGINAL_RATE,		//边际利率
		COL_TOTAL_MULTIPLIER,	//全场倍数
		COL_MARGINAL_MULTIPLIER,//边际倍数
		COL_SETTLEMENT_DATE,	//缴款日
		COL_LISTING_DATE,		//上市日
		COL_HISTORY_ISSUE,		//历史发行
		COL_MAX_COUNT
	};

	typedef enum {
		VIEW_LIST = 0, //列表
		VIEW_CHART	   //图
	}ViewType;

	typedef enum {
		DATE_WEEK = 0,	//周
		DATE_MONTH		//月
	}DateType;

	typedef enum {
		PERIOD_PRE = 0,	//上周(月)
		PERIOD_CUR,		//本周(月)
		PERIOD_NEXT,	//下周(月)
	}Period;
	InterestRateBondIssuance(QWidget* p);

protected:
	virtual SDialog* clone(QWidget* parent = nullptr) override;

private:
	void onTabSelected(int index);
	void onTabViewTypeSelected();
	void onTabDateSelected();
	void onTabPeriodSelected();
	DateType getCurrentDateType() const;
	void updateTab(DateType type);
	void onUpdateListData();
	void onUpdateChartData();

	void getStartEndDate(DateType dateType, Period period, int& dayFrom, int& dayTo);
	bool getBondIndex(int dayFrom, int dayTo, std::vector<int>& vecBonds);

private:
	STabCtrl* m_viewTypeTab;
	STabCtrl* m_dateTab;
	STabCtrl* m_periodTab;
	InterestRateBondList* m_list;
	InterestRateBondChart* m_chart;
};